﻿CREATE PROCEDURE [Messenger].[SP_TuttiMessaggi_CL]
	@Sender nvarchar(50),
	@Receiver nvarchar(50)
AS
	-- Cerca i messaggi di una conversazione (parametri NULLABLE)
	SELECT MessaggioID, Sender, Receiver, TestoMessaggio, IsDelivered, IsRead, TimeStamp_Insert
	FROM Messenger.Messaggio
	WHERE 
		((Receiver = @Receiver OR @Receiver IS NULL) AND (Sender = @Sender OR @Sender IS NULL))
		OR ((Sender= @Receiver OR @Receiver IS NULL) AND (Receiver= @Sender OR @Sender IS NULL))
RETURN 0